package com.ywjt.platformbusiness.store.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.base.BaseActivity;

public class BusinessGoodsTrack extends BaseActivity  implements View.OnClickListener {
    private RecyclerView traceRv; //物流追踪列表
//    private List<Trace.DataDTO.TracesDTO> mTraceList; //物流追踪列表的数据源
//    private TraceAdapter mAdapter;
//    private TextView tvStatus,tvCompanyName,tvLogisticOrder;
//    private Trace bean;
    private LinearLayout llNodata;

    private String expCode="";
    private String expNo="";
    private String goodsCover="";
    private int count=1;
    private ImageView ivImage;
    private TextView tvCount;
    private ImageView ivBack;
    public static void actionStart(Context context,String expCode,String expNo,String goodsCover,int count) {
        Intent intent = new Intent(context, BusinessGoodsTrack.class);
        intent.putExtra("expNo",expNo);
        intent.putExtra("expCode",expCode);
        intent.putExtra("goodsCover",goodsCover);
        intent.putExtra("count",count);
        context.startActivity(intent);
    }

    public static void actionStart(Context context) {
        Intent intent = new Intent(context, BusinessGoodsTrack.class);
        context.startActivity(intent);
    }



    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.business_goods_track;
    }

    @Override
    protected void initView() {
        expNo=getIntent().getStringExtra("expNo");
        expCode=getIntent().getStringExtra("expCode");
        goodsCover=getIntent().getStringExtra("goodsCover");
        count=getIntent().getIntExtra("count",1);
        ivBack=findViewById(R.id.ivBack);
        ivBack.setOnClickListener(this);
//        tvStatus=findViewById(R.id.tvStatus);
//        tvCompanyName=findViewById(R.id.tvCompanyName);
//        tvLogisticOrder=findViewById(R.id.tvLogisticOrder);
        llNodata=findViewById(R.id.llNodata);
        traceRv = (RecyclerView) findViewById(R.id.traceRv);
        ivImage=findViewById(R.id.ivImage);
        tvCount=findViewById(R.id.tvCount);

//        Glide.with(getContext()).load(goodsCover).
//                placeholder(R.mipmap.default_order)
//                .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
//                .into(ivImage);
//        tvCount.setText("共"+count+"件");
      //  getData();

    }

//    //获取物流信息
//    private void getData() {
//        Map<String, String> map = new HashMap<>();
//        map.put("expCode", expCode);//物流公司编码
//        map.put("expNo",expNo);//物流单号
//        new HttpRequest(getContext()).doPost(UrlConstants.goodsOrder_expressQuery, null, map, Trace.class, new HttpStringCallBack() {
//            @RequiresApi(api = Build.VERSION_CODES.M)
//            @Override
//            public void onSuccess(Object result) {
//                if (result instanceof Trace) {
//                     bean=(Trace)result;
//                    if(bean.getCode()==200){
//                        mTraceList = new ArrayList<>();
//                       mTraceList=bean.getData().getTraces();
//                       setView();
//                       initRecyclerView();
//                    }else {
//                        Toast.makeText(getContext(),bean.getMessage(),Toast.LENGTH_SHORT).show();
//                    }
//                }
//            }
//
//            @Override
//            public void onFailure(int code, String msg) {
//                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
//    //设置头部数据
//    public void setView(){
//        tvCompanyName.setText("快递公司："+bean.getData().getShipperName());
//        tvLogisticOrder.setText("快递单号："+bean.getData().getLogisticCode());
//        switch (bean.getData().getState()){
//            case "2":
//                //在途中
//                tvStatus.setText("物流状态：运送中");
//                break;
//            case "3"://签收
//                tvStatus.setText("物流状态：已签收");
//                break;
//            case "4"://问题件
//                tvStatus.setText("物流状态：问题件");
//                break;
//        }
//
//
//    }
//
//    //初始化显示物流追踪的RecyclerView
//    private void initRecyclerView() {
//        if(mTraceList.size()>0){
//            traceRv .setVisibility(View.VISIBLE);
//            llNodata.setVisibility(View.GONE);
//            LinearLayoutManager layoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
//            mAdapter = new TraceAdapter(this, mTraceList,bean.getData().getState());
//            traceRv.setLayoutManager(layoutManager);
//            traceRv.setAdapter(mAdapter);
//        }else {
//            llNodata.setVisibility(View.VISIBLE);
//            traceRv.setVisibility(View.GONE);
//        }
//    }


    @Override
    protected void initData() {

    }

    @Override
    protected int getTitleBarType() {
        return TITLEBAR_NULL;
    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ivBack:
                finish();
                break;
        }
    }
}
